﻿<UserControl x:Class="BillsManager.Views.BillAddEditView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Behaviors="clr-namespace:BillsManager.Views.Behaviors"
             xmlns:Controls="clr-namespace:BillsManager.Views.Controls"
             xmlns:Loc="clr-namespace:BillsManager.Localization;assembly=BillsManager.Localization"
             xmlns:ViewModels="clr-namespace:BillsManager.ViewModels;assembly=BillsManager.ViewModels"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             d:DataContext="{d:DesignInstance Type=ViewModels:BillAddEditViewModel}"
             mc:Ignorable="d">

    <UserControl.Resources>
        <!--<ResourceDictionary Source="Dictionaries\Styles.xaml" />-->
        <ResourceDictionary Source="Themes\Themes.xaml" />
    </UserControl.Resources>

    <UserControl.Background>
        <Binding Mode="OneTime" Source="{StaticResource View.Background}" />
    </UserControl.Background>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
            <ColumnDefinition Width="Auto" MinWidth="150" />
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
            <ColumnDefinition Width="Auto" MinWidth="150" />
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.Region.Spacing.Medium}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
        </Grid.RowDefinitions>

        <!--  Details  -->
        <TextBlock Grid.Row="1"
                   Grid.Column="1"
                   Grid.ColumnSpan="7"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   FontWeight="Bold"
                   Text="{Loc:Translate Details}" />


        <TextBlock Grid.Row="3"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Date}" />
        <DatePicker x:Name="dtpReleaseDate"
                    Grid.Row="3"
                    Grid.Column="3"
                    Width="Auto"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Center"
                    DisplayDateEnd="{Binding DisplayDateEndForReleaseDate,
                                             Mode=OneTime}"
                    FirstDayOfWeek="Monday"
                    SelectedDate="{Binding ReleaseDate}"
                    TabIndex="0" />


        <TextBlock Grid.Row="3"
                   Grid.Column="5"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Due}" />
        <DatePicker Grid.Row="3"
                    Grid.Column="7"
                    Width="Auto"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Center"
                    DisplayDateStart="{Binding ReleaseDate}"
                    FirstDayOfWeek="Monday"
                    SelectedDate="{Binding DueDate}"
                    TabIndex="1" />


        <TextBlock Grid.Row="5"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Paid_toBill}" />
        <CheckBox Grid.Row="5"
                  Grid.Column="3"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Center"
                  IsChecked="{Binding IsPaid}"
                  TabIndex="2" />


        <TextBlock Grid.Row="5"
                   Grid.Column="5"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Payment}" />
        <DatePicker Grid.Row="5"
                    Grid.Column="7"
                    Width="Auto"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Center"
                    DisplayDateStart="{Binding ReleaseDate}"
                    FirstDayOfWeek="Monday"
                    IsEnabled="{Binding IsPaid}"
                    SelectedDate="{Binding PaymentDate}"
                    TabIndex="3" />


        <TextBlock Grid.Row="7"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Amount}" />
        <TextBox Grid.Row="7"
                 Grid.Column="3"
                 HorizontalAlignment="Stretch"
                 VerticalAlignment="Center"
                 Behaviors:TextBoxBehavior.ValueWhenLeftEmpty="0"
                 GotFocus="SelectAllText"
                 GotMouseCapture="SelectAllText"
                 Language="en-US"
                 MaxLines="1"
                 TabIndex="4"
                 Text="{Binding Amount,
                                StringFormat=\{0:0.00##\},
                                ValidatesOnDataErrors=True,
                                ConverterCulture=en-US}"
                 TextAlignment="Right" />


        <TextBlock Grid.Row="7"
                   Grid.Column="5"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Number}" />
        <TextBox Grid.Row="7"
                 Grid.Column="7"
                 HorizontalAlignment="Stretch"
                 VerticalAlignment="Center"
                 GotFocus="SelectAllText"
                 GotMouseCapture="SelectAllText"
                 MaxLines="1"
                 TabIndex="5"
                 Text="{Binding Code,
                                UpdateSourceTrigger=PropertyChanged}" />


        <TextBlock Grid.Row="9"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Agio}" />
        <TextBox Grid.Row="9"
                 Grid.Column="3"
                 HorizontalAlignment="Stretch"
                 VerticalAlignment="Center"
                 Behaviors:TextBoxBehavior.ValueWhenLeftEmpty="0"
                 GotFocus="SelectAllText"
                 GotMouseCapture="SelectAllText"
                 Language="en-US"
                 MaxLines="1"
                 TabIndex="6"
                 Text="{Binding Agio,
                                StringFormat=\{0:0.00##\},
                                ConverterCulture=en-US}"
                 TextAlignment="Right" />


        <TextBlock Grid.Row="9"
                   Grid.Column="5"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Costs}" />
        <TextBox Grid.Row="9"
                 Grid.Column="7"
                 HorizontalAlignment="Stretch"
                 VerticalAlignment="Center"
                 Behaviors:TextBoxBehavior.ValueWhenLeftEmpty="0"
                 GotFocus="SelectAllText"
                 GotMouseCapture="SelectAllText"
                 Language="en-US"
                 MaxLines="1"
                 TabIndex="7"
                 Text="{Binding AdditionalCosts,
                                StringFormat=\{0:0.00##\},
                                ConverterCulture=en-US}"
                 TextAlignment="Right" />


        <TextBlock Grid.Row="11"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Supplier}" />
        <ComboBox x:Name="cbxSupplier"
                  Grid.Row="11"
                  Grid.Column="3"
                  Grid.ColumnSpan="5"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Center"
                  IsEditable="True"
                  IsTextSearchCaseSensitive="False"
                  IsTextSearchEnabled="True"
                  ItemsSource="{Binding AvailableSuppliers,
                                        UpdateSourceTrigger=PropertyChanged}"
                  SelectedItem="{Binding SelectedSupplier,
                                         UpdateSourceTrigger=PropertyChanged,
                                         ValidatesOnDataErrors=True}"
                  TabIndex="8"
                  TextSearch.TextPath="Name">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>


        <TextBlock Grid.Row="13"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Notes}" />
        <TextBox Grid.Row="13"
                 Grid.Column="3"
                 Grid.ColumnSpan="5"
                 Height="48"
                 HorizontalAlignment="Stretch"
                 VerticalAlignment="Center"
                 HorizontalScrollBarVisibility="Disabled"
                 TabIndex="9"
                 Text="{Binding Notes,
                                UpdateSourceTrigger=PropertyChanged,
                                ValidatesOnDataErrors=True}"
                 TextWrapping="Wrap"
                 VerticalScrollBarVisibility="Auto" />


        <StackPanel Grid.Row="15"
                    Grid.Column="1"
                    Grid.ColumnSpan="7"
                    HorizontalAlignment="Right"
                    Orientation="Horizontal">
            <Button Width="80"
                    Command="{Binding ConfirmAddEditAndCloseCommand}"
                    Content="{Loc:Translate Ok}"
                    TabIndex="10">
                <Button.Margin>
                    <Thickness Right="{StaticResource View.MarginSize.Value}" />
                </Button.Margin>
            </Button>
            <Button Width="80"
                    Command="{Binding CancelAddEditAndCloseCommand}"
                    Content="{Loc:Translate Cancel}"
                    IsCancel="True"
                    TabIndex="11" />
        </StackPanel>

    </Grid>
</UserControl>